package com.loren.controller;

import com.loren.entity.DbInfo;
import com.loren.entity.Person;
import com.loren.service.DbInfoService;
import com.loren.service.PersonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class TestController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private DbInfoService dbInfoService;

    @Autowired
    private PersonService personService;

    @GetMapping("/db-info")
    public DbInfo getDbInfo() {
        logger.info("获取DbInfo的信息");
        return this.dbInfoService.getDbInfoDetail();
    }

    @GetMapping("/person")
    public Person getPerson() {
        logger.info("获取Person的信息");
        return this.personService.getPersonInfo();
    }

    @GetMapping("/multiple")
    public Map<String, Object> multipleDataSource2() {
        logger.info("获取Person和DbInfo的信息");
        return this.personService.getMultipleDataSourceInfo();
    }
}
